package com.zyh.kaoshi;

import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        System.out.println("请输入一个字符串：");
        String input = new Scanner(System.in).nextLine();
        lock lock1 = new lock();
        unlock unlock1 = new unlock();
        String lock = lock1.lock(input);
        System.out.println("加密后： " + lock);
        String unlock = unlock1.unlock(lock);
        System.out.println("解密后： " + unlock);
    }
}

class lock {
    public String lock(String str) {
        char[] chs = str.toCharArray();
        for (int i = 0; i < chs.length; i++) {
            chs[i] += 5;
        }
        String s = new String(chs);
        return s;
    }
}

class unlock {
    public String unlock(String str) {
        char[] chs = str.toCharArray();
        for (int i = 0; i < chs.length; i++) {
            chs[i] -= 5;
        }
        String s = new String(chs);
        return s;
    }
}

